package com.suse.common.config.elasticsearch;

import org.elasticsearch.client.RestHighLevelClient;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.elasticsearch.client.ClientConfiguration;
import org.springframework.data.elasticsearch.client.RestClients;

/**
 * <p>
 * Elasticsearch配置类
 * </p>
 *
 * @author 辜玉彬
 * @since 2022-09-04 10:42
 */
@Configuration
@ConditionalOnClass(RestHighLevelClient.class)
public class EsConfig {

    @Bean
    RestHighLevelClient elasticsearchClient() {
        ClientConfiguration configuration = ClientConfiguration.builder()
                .connectedTo("192.168.186.200:9200")
                .build();
        return RestClients.create(configuration).rest();
    }

}
